﻿using System;
using System.ServiceModel;

using SBPweb.Forge.Cryptography;

namespace SBPweb.GoogleDataAPI.Client.Connector.Services
{

    public abstract class ProviderBase<TClient, TContract>
        where TClient : class
        where TContract : class
    {

        #region Protected fields

        private ClientBase<TContract> client = null;
        internal protected CustomCryptographyProvider crypter = new CustomCryptographyProvider();

        #endregion

        #region Constructor logic

        public ProviderBase()
        {
            client = (ServiceConnector.CreateServiceClientInstance<TClient, TContract>(typeof(TClient))) as ClientBase<TContract>;
        }

        #endregion

        #region Property accessors

        internal TClient Client
        {
            get
            {
                return client as TClient;
            }
        }

        #endregion

        #region Methods

        protected internal virtual System.ServiceModel.OperationContextScope GetScope()
        {
            return ServiceConnector.CreateServiceClientScope<TContract>(client);
        }

        #endregion

    }

}